//
//  GWItemsCollectionViewCell.m
//  GiftWanted
//
//  Created by lanou on 15/11/9.
//  Copyright © 2015年 陈文杰. All rights reserved.
//

#import "GWItemsCollectionViewCell.h"
#import "UIImageView+WebCache.h"

@implementation GWItemsCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        CGFloat w = frame.size.width;
//        CGFloat h = frame.size.height;
        
        _img = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, w, w)];
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, w, w-10, 50)];
        _titleLabel.font = [UIFont systemFontOfSize:15];
        _titleLabel.numberOfLines = 2;
        _priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, w+50, w/2-10, 20)];
        _priceLabel.font = [UIFont systemFontOfSize:12];
        _priceLabel.textColor = [UIColor redColor];
        _countLabel = [[GWILView alloc] initWithFrame:CGRectMake(w/2, w+50, w/2-5, 20)];
        _countLabel.img.image = [UIImage imageNamed:@"like2"];
        _countLabel.img.frame = CGRectMake(5, 3, 15, 15);
        _countLabel.label.textColor = [UIColor lightGrayColor];
        
        [self.contentView addSubview:_img];
        [self.contentView addSubview:_titleLabel];
        [self.contentView addSubview:_priceLabel];
        [self.contentView addSubview:_countLabel];
    }
    return self;
}

- (void)setConfigureModel:(GWHotItemsModel *)configureModel {
    
    _configureModel = configureModel;
    [_img sd_setImageWithURL:[NSURL URLWithString:configureModel.cover_image_url]];
    _titleLabel.text = configureModel.name;
    _priceLabel.text = [@"￥ " stringByAppendingFormat:@"%@", configureModel.price];
    _countLabel.label.text = [NSString stringWithFormat:@"%@", configureModel.favorites_count];
}

@end
